﻿using _003_MVVM的Messenger.Message;
using CommunityToolkit.Mvvm.Messaging;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _003_MVVM的Messenger
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            new RecWindow().Show();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //执行消息发送  都可以，一般用WeakReferenceMessenger
            //WeakReferenceMessenger
            //StrongReferenceMessenger

            WeakReferenceMessenger.Default.Send(new UiMessage("From MainWindow"));
        }

        private void Button_Click2(object sender, RoutedEventArgs e)
        {
            string result = WeakReferenceMessenger.Default.Send<Ui2Message>();

        }
    }
}